﻿using System.Xml.Serialization;

namespace Antix.Mail.Smtp.Impostor
{
    public class ForwardMessageStorageConfiguration : MessageStorageConfiguration<ForwardMessageStorage>
    {
        int _port;

        /// <summary>
        /// </summary>
        [XmlElement]
        public string ForwardTo { get; set; }

        /// <summary>
        /// </summary>
        [XmlElement]
        public string Server { get; set; }

        /// <summary>
        /// </summary>
        [XmlElement]
        public int Port
        {
            get { return _port; }
            set
            {
                _port = value;
                if (_port == 587) UseTls = true;
            }
        }

        [XmlElement]
        public bool UseTls { get; set; }

        [XmlElement]
        public string User { get; set; }

        [XmlElement]
        public string Password { get; set; }

        [XmlElement]
        public string PrefixSubject { get; set; }

        [XmlElement]
        public string From { get; set; }

        public override ForwardMessageStorage Create(HostConfiguration hostConfig)
        {
            var messageStorage = new ForwardMessageStorage(this);

            return messageStorage;
        }
    }
}